-- weaken_mon1
-- created by wangy
-- 削弱目标(根据固定百分比，与攻击等属性无关)

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 如果免疫了该技能
        if SkillM.immunitySkill(source, target, skillId) then
            SkillM.getSequence(target):immunity(source, target, skillId);
            return {};
        end

        local effectRound = -1;
        extra = extra or {};
        local lastRound = extra.lastRound;

        if type(lastRound) == "number" then
            effectRound = round + lastRound;
        elseif para[5] > 0 then
            effectRound = round + para[5];
        end

        -- 威力
        local force = para[4];
        local prop = { para[2], para[3], force, effectRound, }

        local rule = para[1];
        local condition = {
            ["prop"] = prop,
            ["end_round"] = effectRound,
        };

        -- 附加状态
        CombatStatusM.applyStatus(target, rule, condition);

        -- 返回作用目标
        return { target, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return {  arr[1],tonumber(arr[2]), arr[3], tonumber(arr[4]), tonumber(arr[5] or -1), };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        -- 威力
        local force = para[4];
        -- 效果
        desc = string.gsub(desc, "{weaken_mon1}", math.abs(force));

        -- 回合数
        desc = string.gsub(desc, "{round}", para[5]);

        return desc;
    end,
};
